package br.com.inventario.jdbc.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import br.com.inventario.jdbc.ConnectionFactory;
import br.com.inventario.jdbc.modelos.Inventario;
import br.com.inventario.jdbc.modelos.Parametro;

public class ParametroDAO {

	private final Session session;

	public ParametroDAO() {
	    this.session = CriadorDeSession.getSession();
	  }

public void adiciona(Parametro oparametro) {
	
    Transaction tx = session.beginTransaction();
	session.save(oparametro);
	tx.commit();
	session.close();
	}

public List<Parametro> lista() {
	
	Transaction tx = session.beginTransaction();
	List <Parametro> Parametros = session.createQuery("from Parametro").list();
	tx.commit();
	return Parametros;
	}

public Parametro buscaParametro(int id) {
	return (Parametro) this.session.load(Parametro.class, id);
	}

public void altera(Parametro oparametro) {
		
	Transaction tx = session.beginTransaction();
	session.update(oparametro);
	tx.commit();
	session.close();
	}

public void remove(Parametro oparametro) {
	
	Transaction tx = session.beginTransaction();
	session.delete(oparametro);
	tx.commit();
	session.close();

	}

}
